<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/vue.min.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="./lib/elementui-index.js"></script>
    <script src="./lib/axios.min.js"></script>
    <script src="./lib/token.js"></script>
</head>
<body>
    <div id="app">
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="公司名称">
              <el-input v-model="form.cname"></el-input>
            </el-form-item>

            <el-form-item label="公司联系人">
                <el-input v-model="form.cuser"></el-input>
            </el-form-item>
            <el-form-item label="联系方式">
                <el-input v-model="form.ctel" type="number"></el-input>
            </el-form-item>
            <el-form-item label="地址">
                <el-input v-model="form.caddr"></el-input>
            </el-form-item>
            <el-form-item label="联系方式">
                <el-input v-model="form.cperson"></el-input>
            </el-form-item>

            <el-form-item>
                <template>
                    <el-button type="primary" @click="updateCustomer">修改</el-button>
                </template>
            </el-form-item>
          </el-form>
    </div>


    <script>
        new Vue({
            el:"#app",
            data() {
                return {
                    form: {
                    },
                }
            },
            methods: {
                updateCustomer(){
                    console.log(this.form)
                    axios.put("http://localhost:8001/production/customer/updateCustomer",this.form)
                    .then(res=>{
                        console.log(res.data)
                        if(res.data.code === 20000){
                            this.$message.success("添加成功")
                        }else{
                            this.$message.error("添加失败")
                        }
                    })
                },
                open() {
                    this.$confirm('是否添加订单?', '提示', {
                    confirmButtonText: '添加',
                    cancelButtonText: '取消',
                    type: 'warning'
                    }).then(() => {
                        this.$message({
                            type: 'success',
                            message: '添加成功'
                        }); 
                        this.addProduct()
                        location.href = "addproduct.html"
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消'
                        });        
                    });
                },
                queryOrder(){
                    sessionStorage.ooid = '';
                    location.href = "order.html"
                }
            },
            created(){
                this.form = JSON.parse(sessionStorage.customer)
            }
        })
    </script>
</body>
</html>